using System;
using Webshop20.Domain.Common;

namespace Webshop20.Domain.Shared.Products.Core
{
    [Serializable]
    public class Product : Entity 
    {
        public Product(decimal price,
                       string name,
                       string description,
                       string image,
                       string purchasOrderNumber,
                       bool isOutdated, 
                       Category category, Producer producer, Discount discount)
        {
            NetPrice = price;
            Name = name;
            Description = description;
            Image = image;
            PurchasOrderNumber = purchasOrderNumber;
            IsOutdated = isOutdated;
            ProductCategory = category;
            Producer = producer;
            Discount = discount;
        }

        public Product()
        {
            
        }

        public virtual decimal NetPrice { get; private set; }
        public virtual string Name { get; private set; }
        public virtual string Description { get; private set; }
        public virtual string Image { get; private set; }
        public virtual string PurchasOrderNumber { get; private set; }
        public virtual bool IsOutdated { get; set; }
        public virtual Producer Producer { get; private set; }
        public virtual Category ProductCategory { get; private set; }
        public virtual Discount Discount { get; private set; }

        public virtual decimal CalculateGrossPrice(ISalesTax salesTax)
        {
            return NetPrice + salesTax.Calculate(NetPrice);
        }

        public virtual decimal CalculateTotal(ISalesTax salesTax, DateTime calculationDate)
        {
            return CalculateGrossPrice(salesTax) - Discount.Calculate(NetPrice, calculationDate);
        }

         
    }
}